import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: 'Dashboard', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/information', // 资料
    redirect: '/information/project',
    name: 'Information',
    alwaysShow: true,
    component: Layout,
    meta: {
      title: 'Information',
      icon: 'Information'
    },
    children: [
      {
        path: 'constant', // 常量列表
        component: () => import('@/views/information/constant/index'),
        name: 'Constant',
        meta: { title: 'constant' }
      },
      {
        path: 'remaining', // 余下列表
        component: () => import('@/views/information/remaining/index'),
        name: 'remaining',
        meta: { title: 'remaining' }
      },
      {
        path: 'fund', // 资金构成
        component: () => import('@/views/information/fund/index'),
        name: 'fund',
        meta: { title: 'fund' }
      }
    ]
  },
  {
    path: '/income', // 收入支出
    component: Layout,
    redirect: '/dashboard',
    alwaysShow: true,
    name: 'income',
    meta: {
      title: 'income',
      icon: 'income'
    },
    children: [
      {
        path: 'incomeProject', // 明细
        component: () => import('@/views/income/incomeProject/index'), // Parent router-view
        name: 'incomeProject',
        meta: { title: 'incomeProject' }
      }
    ]
  },
  {
    path: '/statistics', // 统计
    component: Layout,
    redirect: '/dashboard',
    alwaysShow: true,
    name: 'statistics',
    meta: {
      title: 'statistics',
      icon: 'statistics'
    },
    children: [
      {
        path: 'propertyStatistics', // 资产统计
        component: () => import('@/views/statistics/propertyStatistics/index'),
        name: 'propertyStatistics',
        meta: { title: 'propertyStatistics' }
      },
      {
        path: 'creditStatistics', // 进账统计
        component: () => import('@/views/statistics/creditStatistics/index'),
        name: 'creditStatistics',
        meta: { title: 'creditStatistics' }
      },
      {
        path: 'exceedStatistics', // 超出统计
        component: () => import('@/views/statistics/exceedStatistics/index'),
        name: 'exceedStatistics',
        meta: { title: 'exceedStatistics' }
      }
    ]
  }
  // {
  //   path: '/report', // 报表
  //   component: Layout,
  //   redirect: '/dashboard',
  //   name: 'Report',
  //   meta: {
  //     title: 'Report',
  //     icon: 'report'
  //   },
  //   children: [
  //     {
  //       path: 'moveTable', // 搬砖
  //       component: () => import('@/views/report/moveTable/index'),
  //       name: 'moveTable',
  //       meta: { title: 'MoveTable' }
  //     },
  //     {
  //       path: 'cilpTable', // 剪辑
  //       component: () => import('@/views/report/cilpTable/index'),
  //       name: 'cilpTable',
  //       meta: { title: 'CilpTable' }
  //     },
  //     {
  //       path: 'foundTable', // 资金盘
  //       component: () => import('@/views/report/foundTable/index'),
  //       name: 'foundTable',
  //       meta: { title: 'FoundTable' }
  //     }
  //   ]
  // }
]

const createRouter = () =>
  new Router({
    // mode: 'hash',
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
